﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Orders.aspx.cs" Inherits="Orders" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Orders Page</title>

    <script language="JavaScript" src="js/CalendarPopup.js"></script>

    <script language="JavaScript">
        var cal = new CalendarPopup();
    </script>

    <style>
        select
        {
            width: 144px !important;
        }
        input
        {
            width: 140px !important;
        }
        .style2
        {
            height: 30px;
        }
        .button
        {
        	width: 80px ! important; 
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table border="0" cellpadding="1" cellspacing="1" width="100%">
        <tr>
            <td width="15%">
                ID:
            </td>
            <td>
                <asp:TextBox ID="txtOrderID" runat="server" ReadOnly="true" Enabled="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                Customer:
            </td>
            <td>
                <asp:DropDownList ID="DDLCustID" runat="server" Height="22px" Width="128px">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                Employees:
            </td>
            <td>
                <asp:DropDownList ID="DDLEmpID" runat="server" Height="22px" Width="128px">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                Order Date:
            </td>
            <td>
                <asp:TextBox data-id="txtOrderDate" ID="txtOrderDate" runat="server"></asp:TextBox>
                <a href="#" onclick="cal.select(document.querySelector('[data-id=txtOrderDate]'),'anchor1','yyyy/MM/dd'); return false;"
                    name="anchor1" id="anchor1">select</a>
            
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                    ControlToValidate="txtOrderDate" ErrorMessage="Can not be null"></asp:RequiredFieldValidator>
            
            </td>
        </tr>
        <tr>
            <td class="style2">
                Required Date:
            </td>
            <td class="style2">
                <asp:TextBox ID="txtRequiredDate" data-id="txtRequiredDate" runat="server"></asp:TextBox>
                <a href="#" onclick="cal.select(document.querySelector('[data-id=txtRequiredDate]'),'anchor1','yyyy/MM/dd'); return false;"
                    name="anchor1" id="a1">select</a>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtOrderDate"
                    ControlToValidate="txtRequiredDate" ErrorMessage="Required date must be later than Order Date"
                    Operator="GreaterThan" Type="Date" Display="Dynamic"></asp:CompareValidator>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                    ControlToValidate="txtRequiredDate" Display="Dynamic" 
                    ErrorMessage="Can not be null"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Shipped Date:
            </td>
            <td>
                <asp:TextBox ID="txtShippedDate" data-id="txtShippedDate" runat="server"></asp:TextBox>
                <a href="#" onclick="cal.select(document.querySelector('[data-id=txtShippedDate]'),'anchor1','yyyy/MM/dd'); return false;"
                    name="anchor1" id="a2">select</a>
                <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="txtOrderDate"
                    ControlToValidate="txtShippedDate" ErrorMessage="Shipped date must latter than Order date"
                    Operator="GreaterThan" Type="Date"></asp:CompareValidator>
            </td>
        </tr>
        <tr>
            <td>
                Shipper:
            </td>
            <td>
                <asp:DropDownList ID="DDLShipperID" runat="server" Height="22px" Width="125px">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                Freight:
            </td>
            <td>
                <asp:TextBox ID="txtFreight" runat="server"></asp:TextBox>
                <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txtFreight"
                    ErrorMessage="Error Input" MaximumValue="99999999" MinimumValue="0" 
                    Type="Double"></asp:RangeValidator>
            </td>
        </tr>
        <tr>
            <td>
                Ship Name:             </td>
            <td>
                <asp:TextBox ID="txtShipName" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtShipName"
                    ErrorMessage="Can not be null"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Ship Address:
            </td>
            <td>
                <asp:TextBox ID="txtShipAddress" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtShipAddress"
                    ErrorMessage="Can not be null"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Ship City:
            </td>
            <td>
                <asp:TextBox ID="txtShipCity" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtShipCity"
                    ErrorMessage="Can not be null"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Ship Region:
            </td>
            <td>
                <asp:TextBox ID="txtShipRegion" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                Ship Postal Code:
            </td>
            <td>
                <asp:TextBox ID="txtShipPostalCode" runat="server"></asp:TextBox>
                <asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="txtShipPostalCode"
                    ErrorMessage="Invalid Input" MaximumValue="99999" MinimumValue="10000" 
                    Type="Integer"></asp:RangeValidator>
            </td>
        </tr>
        <tr>
            <td>
                Ship Country:
            </td>
            <td>
                <asp:DropDownList ID="DDLShipCountry" runat="server" Height="22px" Width="127px">
                    <asp:ListItem>Finland</asp:ListItem>
                    <asp:ListItem>Brazil</asp:ListItem>
                    <asp:ListItem>USA</asp:ListItem>
                    <asp:ListItem>Italy</asp:ListItem>
                    <asp:ListItem>Germany</asp:ListItem>
                    <asp:ListItem>Mexico</asp:ListItem>
                    <asp:ListItem>Argentina</asp:ListItem>
                    <asp:ListItem>Switzerland</asp:ListItem>
                    <asp:ListItem>Sweden</asp:ListItem>
                    <asp:ListItem>Austria</asp:ListItem>
                    <asp:ListItem>UK</asp:ListItem>
                    <asp:ListItem>Poland</asp:ListItem>
                    <asp:ListItem>Canada</asp:ListItem>
                    <asp:ListItem>Ireland</asp:ListItem>
                    <asp:ListItem>France</asp:ListItem>
                    <asp:ListItem>Norway</asp:ListItem>
                    <asp:ListItem>Venezuela</asp:ListItem>
                    <asp:ListItem>Belgium</asp:ListItem>
                    <asp:ListItem>Spain</asp:ListItem>
                    <asp:ListItem>Denmark</asp:ListItem>
                    <asp:ListItem>Portugal</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
    </table>
    <br />
    <table>
        <tr>
            <td>
                <asp:Button CssClass = "button" ID="btnNew" runat="server" Text="New" OnClick="btnNew_Click" CausesValidation="False"
                    Width="100px" />
                <asp:Button CssClass = "button" ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" Width="100px" />
                <asp:Button CssClass = "button" ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click"
                    Width="100px" />
                <asp:Button CssClass = "button" ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click"
                    Width="100px" CausesValidation="False" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Button ID="btnSeeDetail" runat="server" OnClick="btnSeeDetail_Click" Text="See Order Details"
                    CausesValidation="False" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:TextBox ID="txtSearch" runat="server" Width="148px" data-id= "txtSearch"></asp:TextBox>
                <a href="#" onclick="cal.select(document.querySelector('[data-id=txtSearch]'),'anchor1','yyyy/MM/dd'); return false;"
                    name="anchor1" id="a3">select</a>
                <asp:DropDownList ID="DDLSearchBy" runat="server" witdh="148px" Height="22px">
                    <asp:ListItem>Order Date</asp:ListItem>
                    <asp:ListItem>Required Date</asp:ListItem>
                    <asp:ListItem>Shipped Date</asp:ListItem>
                </asp:DropDownList>
                <asp:Button CssClass = "button" ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
                    CausesValidation="False" Width="100px" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Button CssClass = "button" ID="btnReload" runat="server" Text="Reload" OnClick="btnReload_Click"
                    CausesValidation="False" Width="100px" />
            </td>
        </tr>
    </table>
    <br />
    <asp:GridView ID="gvOrders" runat="server" OnSelectedIndexChanged="gvOrders_SelectedIndexChanged"
        OnPageIndexChanging="gvOrders_PageIndexChanging" AutoGenerateColumns="False">
        <Columns>
            <asp:BoundField DataField="orderid" HeaderText="ID" />
            <asp:BoundField DataField="custid" HeaderText="Customer ID" />
            <asp:BoundField DataField="empid" HeaderText="Employee ID" />
            <asp:BoundField DataField="orderdate" HeaderText="Order Date" />
            <asp:BoundField DataField="requireddate" HeaderText="Required Date" />
            <asp:BoundField DataField="shippeddate" HeaderText="Shipped Date" />
            <asp:BoundField DataField="shipperid" HeaderText="Shipper ID" />
            <asp:BoundField DataField="freight" HeaderText="Freight" />
            <asp:BoundField DataField="shipname" HeaderText="Ship Name" />
            <asp:BoundField DataField="shipaddress" HeaderText="Ship Address" />
            <asp:BoundField DataField="shipcity" HeaderText="Ship City" />
            <asp:BoundField DataField="shipregion" HeaderText="Ship Region" />
            <asp:BoundField DataField="shippostalcode" HeaderText="Ship Postal Code" />
            <asp:BoundField DataField="shipcountry" HeaderText="Ship Country" />
        </Columns>
    </asp:GridView>
    </asp:Content>
